package main

import (
	"encoding/xml"
	"fmt"
)

// Human struct
type Human struct {
	Name      string `xml:"Name"`           // 对应Name标签
	Age       int    `xml:"Age"`            // 对应Age标签
	Id        int    `xml:"Id"`             // 对应Id标签
	FirstName string `xml:"NameInfo>First"` // 对应Namefo下的First标签
	LastName  string `xml:"NameInfo>Last"`  // 对应NameInfo下的Last标签
}

func main() {
	v := &Human{Name: "TheShy", Age: 19, Id: 1, FirstName: "zhang", LastName: "jizhou"}
	resultXml, err := xml.MarshalIndent(v, " ", " ")
	if err != nil {
		panic(err)
	}
	fmt.Print(xml.Header)
	fmt.Println(string(resultXml))
}
